import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Interface {
    public static void main(String args[]){
        try{
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        }
        catch(ClassNotFoundException e){
            System.out.println("加载驱动失败");
            System.exit(0);
        }
        InterfaceWin win=new InterfaceWin();
    }
}

class InterfaceWin extends JFrame implements ActionListener{
    JLabel welcome1,welcome2,copyRight;
    JButton Register,Login,Exit;
    Box baseBox;
    RegisterWin registerWin;
    LoginWin loginWin;
    InterfaceWin(){
        setTitle("学生管理系统界面");
        welcome1=new JLabel("欢迎使用");
        welcome1.setFont(new Font("楷体", Font.BOLD,20));
        welcome2=new JLabel("学生管理系统");
        welcome2.setFont(new Font("楷体", Font.BOLD,20));
        copyRight=new JLabel("All Rights Reserved");
        copyRight.setForeground(Color.GRAY);
        copyRight.setFont(new Font("宋体",Font.ITALIC,10));

        Register=new JButton("注册");
        Register.addActionListener(this);
        Login=new JButton("登录");
        Login.addActionListener(this);
        Exit=new JButton("退出");
        Exit.addActionListener(this);

        setLayout(null);
        add(welcome1);
        welcome1.setBounds(150,0,100,70);
        add(welcome2);
        welcome2.setBounds(130,60,200,20);
        add(copyRight);
        copyRight.setBounds(140,290,100,100);

        baseBox=Box.createVerticalBox();
        baseBox.add(Register);
        baseBox.add(Box.createVerticalStrut(40));
        baseBox.add(Login);
        baseBox.add(Box.createVerticalStrut(40));
        baseBox.add(Exit);
        add(baseBox);
        baseBox.setBounds(160,120,100,180);
        setBounds(700,300,400,400);
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public void actionPerformed(ActionEvent event){
        if(event.getSource()==Register){
            this.dispose();
            registerWin=new RegisterWin("注册窗口");
        }
        else if(event.getSource()==Login){
            this.dispose();
            loginWin=new LoginWin("登录窗口");
        }
        else if(event.getSource()==Exit){
            if(JOptionPane.showConfirmDialog(this,"是否退出","提示",JOptionPane.YES_NO_CANCEL_OPTION)==JOptionPane.YES_OPTION)
                System.exit(0);
        }
    }
}